<!-- application/views/scripts/manage/index.phtml -->
<?php 

/* @var $v_messages X_Page_ItemList_Message */
$v_messages = $this->messages;

/* @var $v_news X_Page_ItemList_News */
$v_news = $this->news;

/* @var $v_actionLinks X_Page_ItemList_ActionLink */
$v_actionLinks = $this->actionLinks;

/* @var $v_manageLinks X_Page_ItemList_ManageLink */
$v_manageLinks = $this->manageLinks;

/* @var $v_statistics X_Page_ItemList_Statistics */
$v_statistics = $this->statistics;

?>
<?php $this->headScript()->appendFile($this->baseUrl("/js/manage/index.js")); ?>
<?php $this->headScript()->appendFile($this->baseUrl("/js/jquery.loopedslider.js")); ?>
<?php $this->headScript()->captureStart(Zend_View_Helper_Placeholder_Container_Abstract::APPEND); ?>

$(function(){
	$("#manage-news").loopedSlider({
		container: 'slider-container',
		containerClick: false,
		slidespeed: 500,
		fadespeed: 500,
		addPagination: true,
		pagination: 'slider-pagination'
	});
	
	$('#manage-news .slider-container').hide();
	$('#manage-news ul li').click(function (){
		$('#manage-news .slider-container').fadeIn();
	});
	
});

<?php $this->headScript()->captureEnd(); ?>

<?php $this->headTitle()->prepend('Home'); ?>

<?php if ( count($v_messages->getItems()) ) :?>
<div class="span-24 last" id="manage-messages">
	<ul>
		<?php foreach ($v_messages->getItems() as $i => $message ): ?>
			<?php /* @var $message X_Page_Item_Message */ ?>
			<li class="<?php echo $message->getType(); ?>">
				<img src="<?php echo @$this->baseUrl("/images/msg_{$message->getType()}.png");?>" alt="<?php echo $message->getType(); ?>" />
				<?php echo $message->getLabel(); ?>
			</li>
		<?php endforeach; ?>
	</ul>
</div>
<?php endif; ?>

<?php if ( $v_news != null && count($v_news->getItems()) ) :?>
<div class="span-24 last" id="manage-news">
	<div class="slider-container">
		<div class="slides">
			<?php foreach ($v_news->getItems() as $i => $news) : ?>
				<?php /* @var $news X_Page_Item_News */ ?>
				<div class="manage-news-article" <?php echo ( $news->getTab() != null ? "title=\"{$news->getTab()}\"" : '' ); ?>>
					<?php if ( $news->getLabel() != '' ) : ?>
						<h3><?php echo $news->getLabel(); ?></h3>
					<?php endif; ?>
					<?php echo $news->getContent(); ?>
				</div>
			<?php endforeach; ?>
		</div>
	</div>
	<!-- 
	<a href="#" class="previous">
		<img alt="prev" src="<?php echo $this->baseUrl('/images/left_arrow_slider.png'); ?>">
	</a>
	<a href="#" class="next">
		<img alt="next" src="<?php echo $this->baseUrl('/images/right_arrow_slider.png'); ?>">
	</a>
	 -->
</div>
<?php endif; ?>

<!-- First class links -->
<div class="span-24 last manage-container" id="manage-maincontainer">
	<div class="span-24 last header">
		<h2><?php echo X_Env::_('manage_mainbox_header'); ?></h2>
	</div>
	<div class="span-23 last boxes box">
		<div class="span-15">
			<?php foreach ($this->coreLinks as $i => $link ): ?>
				<div class="span-4 box clickable">
					<h4><?php echo $link['title']; ?></h4>
					<center>
						<img alt="<?php echo $link['label']; ?>" class="thumb" src="<?php echo $this->baseUrl($link['icon']);?>" />
					</center>
					<a href="<?php echo $link['link']?>">
						<img class="arrow" src="<?php echo $this->baseUrl('/images/right_arrow.png'); ?>" />
						<?php echo $link['label']?>
					</a>
				</div>
			<?php endforeach; ?>
		</div>
		<?php if ( $v_actionLinks != null && count($v_actionLinks->getItems()) ) :?>
			<div class="span-7 box last">
				<h4><?php echo X_Env::_('manage_goto_actionstitle'); ?></h4>
				<div class="scrollable">
					<ul class="hoverable">
						<?php foreach ( $v_actionLinks->getItems() as $i => $link) :?>
							<?php /* @var $link X_Page_Item_ActionLink */ ?>
							<?php
								$_link = '';
								if ( $link->isUrl() ) {
									$_link = $link->getLink();
								} else {
									$_link = $this->url($link->getLink(), $link->getRoute(), $link->isReset());
								}
							?>
							<li>
								<a href="<?php echo $_link; ?>">
									<?php if ( $link->getIcon() != null ) : ?>
										<img class="icon" src="<?php echo $this->baseUrl($link->getIcon()); ?>" />
									<?php else: ?>
										<img class="icon" src="<?php echo $this->baseUrl('/images/right_arrow.png'); ?>" />								
									<?php endif; ?>
									<?php echo $link->getLabel(); ?>
								</a>
							</li>
						<?php endforeach; ?>
					</ul>
				</div>
			</div>
		<?php endif; ?>		
	</div>
</div>

<!-- Second class links -->
<div class="span-24 last manage-container" id="manage-altcontainer">
	<div class="span-24 header last">
		<h2><?php echo X_Env::_('manage_altbox_header'); ?></h2>
	</div>
	<div class="span-23 boxes box last">
		<div class="span-15">
			<?php foreach ($v_manageLinks->getItems() as $i => $link ): ?>
				<?php /* @var $link X_Page_Item_ManageLink */ ?>
				<div class="span-4 box clickable">
					<h4><?php echo $link->getTitle(); ?></h4>
					<div class="span-1">
						<?php if ( $link->getIcon() != null ):?>
							<img alt="<?php echo $link->getLabel(); ?>" class="thumb" src="<?php echo $this->baseUrl($link->getIcon());?>" />
						<?php else:?>
							<img alt="<?php echo $link->getLabel(); ?>" class="thumb" src="<?php echo $this->baseUrl('/images/manage/plugin.png');?>" />
						<?php endif;?>
					</div>
					<div class="span-3 last mainlink">
						<a href="<?php echo $link->isUrl() ? $link->getLink() : $this->url($link->getLink(), $link->getRoute(), $link->isReset()); ?>">
							<img class="arrow" src="<?php echo $this->baseUrl('/images/right_arrow.png'); ?>" />
							<?php echo $link->getLabel() ?>
						</a>
					</div>
					<?php if ( count($link->getSubinfos()->getItems()) ):?>
						<ul>
							<?php foreach ( $link->getSubinfos()->getItems() as $j => $info) :?>
								<?php /* @var $info X_Page_Item_ActionLink */ ?>
								<li>
									<a href="<?php echo $info->isUrl() ? $info->getLink() : $this->url($info->getLink(), $info->getRoute(), $info->isReset()); ?>"><?php echo $info->getLabel(); ?></a>
								</li>
							<?php endforeach; ?>
						</ul>
					<?php endif;?>
				</div>
			<?php endforeach; ?>
		</div>
		<?php if ( $v_statistics != null && count($v_statistics->getItems() ) ) :?>
			<div class="span-8 last" id="manage-statistics">
				<h3><?php echo X_Env::_('manage_statistics'); ?></h3>
				<?php foreach ($v_statistics->getItems() as $i => $statistic) : ?>
					<?php /* @var $statistic X_Page_Item_Statistic */ ?>
					<div class="span-8 last statistic">
						<div class="span-7 last box title clickable">
							<div class="boxitem-stackicon ui-state-default" title="Mostra">
								<span class="ui-icon ui-icon-triangle-1-s">Mostra</span>
							</div>
							<h4><?php echo $statistic->getTitle() ?></h4>
						</div>
						<div class="span-7 box last folded">
							<?php if ( $statistic->getLink() != null ) :?>
								<?php 
								$provider = $statistic->getLink();
								$params = clone $provider;
								unset($params['action']);
								unset($params['controller']);
								unset($params['module']);
								?>
								<?php echo $this->action(
										@$provider['action'],
										@$provider['controller'],
										@$provider['module'],
										@$params); ?>
							<?php else:?>
								<ul>
									<?php foreach ( @$statistic->getStats() as $i => $stat) :?>
										<li><?php echo $stat; ?></li>
									<?php endforeach; ?>
								</ul>
							<?php endif;?>
						</div>
					</div>
				<?php endforeach; ?> 
			</div>
		<?php endif; ?>		
	</div>
</div>
